package com.yinxun.dao.phoenix;

import com.yinxun.dto.PHRDto;
import com.yinxun.entity.UserInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by 何建哲 on 18-5-31.
 */
@Mapper
public interface PHRInfoDao {

 public List<UserInfo> findAll();

  //@Insert("upsert into PHR (ID,NAME) VALUES (#{user.id},#{user.name})")
  //public void addUser(@Param("user") UserInfo userInfo);
  @Insert("upsert into PHR (ACCOUNT_MEMBERID，ACCOUNTNO,ADVICEDTO,CLINICDATE,CLINICHOSPITAL,CLINICDEPARTMENT,DOCTOR,CHIEFCOMPLAINT,DIAGNOSIS,INSPECTION,LISTEN,INQUIRY,PALPATION,MEMBERID,STARTTIME,ENDTIME,TAKEFREQUENCY,TAKEMETHOD,MEDICINES,RECORDPICS) VALUES (#{phr.account_memberId}，#{phr.accountno},#{phr.advicedto},#{phr.clinicdate},#{phr.clinichospital},#{phr.clinicdepartment},#{phr.doctor},#{phr.chiefcomplaint},#{phr.diagnosis},#{phr.inspection},#{phr.listen},#{phr.inquiry},#{phr.palpation},#{phr.memberid},#{phr.starttime},#{phr.endtime},#{phr.takefrequency},#{phr.takemethod},#{phr.medicines},#{phr.recordpics})")
  public void addPhr(@Param("phr") PHRDto phrDto);

 @Delete("delete from USER WHERE ID=#{id}")
  public void deleteUser(@Param("id") int id);

  @Results( value = {
          @Result(property = "id", column = "ID", id = true),
          @Result(property = "name", column = "NAME")
  })
  @Select("select * from USER WHERE ID=#{id}")
  public UserInfo findById(int id);

  @Results( value = {
          @Result(property = "id", column = "ID", id = true),
          @Result(property = "name", column = "NAME")
  })
  @Select("select * from USER WHERE NAME=#{name}")
  public UserInfo getUserByName(@Param("name") String name);

  @Results( value = {
          @Result(property = "id", column = "ID", id = true),
          @Result(property = "name", column = "NAME")
  })
  @Select("select * from USER")
  public List<UserInfo> getUsers();


  @Results( value = {
          @Result(property = "id", column = "ID", id = true),
          @Result(property = "name", column = "NAME")
  })
 @Select("select * from USER left join bj on user.id= bj.user_id where id=3")
 public List<UserInfo> getUsers1();
}
